package org.e_gold.dao.impl;

import org.e_gold.dao.UserAccountDAO;
import org.e_gold.model.UserAccount;
import org.hibernate.Criteria;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

@Repository
public class UserAccountDAOImpl extends AbstractGenericDAO<UserAccount> implements UserAccountDAO {

    public UserAccountDAOImpl() {

        super(UserAccount.class);
    }

    @Override
    @Transactional
    public UserAccount getCurrentUser() {

        Criteria criteria = getCurrentSession().createCriteria(UserAccount.class);
        criteria.setFirstResult(0);
        if (criteria.list().size() > 0) {
            return (UserAccount) criteria.list().get(0);
        }
        return null;
    }
}
